import axios from 'axios'
export default {
  loadUser(store,token){

  },
  loadTestRule(store,tid){
    axios.get("/api/testRule.json?tid=" + tid).then((res)=>{
      res=res.data
      if(res.ret && res.data){
        const data = res.data
        store.commit('changeTestRule',data)
      }
    })
  },
  loadQuestion(store,data){
    let tid = data.tid
    let answer = data.answer
    let question_id =data.question_id
    let token =data.token
    axios(`/api/test.json?tid=${tid}&answer=${answer}&question_id=${question_id}&token=${token}`).then((res)=>{
      res=res.data
      if(res.ret && res.data){
        const data = res.data
        store.commit('changeQuestion',data)
      }
    })
  },

  loadNext(store,data){
    let tid = data.tid
    let answer = data.answer
    let question_id =data.question_id
    let token =data.token
    axios(`/api/nextTest.json?tid=${tid}&answer=${answer}&question_id=${question_id}&token=${token}`).then((res)=>{
      res=res.data
      if(res.ret && res.data){
        const data = res.data
        store.commit('changeQuestion',data)
      }
    })
  },

  loadComment(store,commentType){
    let aid = commentType.aid
    console.log(commentType.aid)
    let type = commentType.type
    axios.get(`/api/comment.json?aid=${aid}&type=${type}`).then((res)=>{
      res=res.data
      if(res.ret && res.data){
        const data =res.data
        store.commit('changeComment',data.comment_list)
      }
    })
  }


}
